package com.hzhc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzhc.entity.CntrChargeDetail;
import com.hzhc.mapper.CntrChargeDetailMapper;
import com.hzhc.service.CntrChargeDetailService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.CntrChargeDetailVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 集装箱计费明细 服务实现类
 * </p>
 *
 * @author 功不唐捐
 * @since 2024-06-12
 */
@Service
@RequiredArgsConstructor
public class CntrChargeDetailServiceImpl extends ServiceImpl<CntrChargeDetailMapper, CntrChargeDetail> implements CntrChargeDetailService {

    @Override
    public List<CntrChargeDetailVo> getAllChargeDetail(CntrChargeDetailVo vo, Page<CntrChargeDetailVo> pagination) {
        IPage<CntrChargeDetailVo> list = baseMapper.getAllChargeBill(pagination, vo);
        return list.getRecords();
    }

    @Override
    public ResultUtil<T> editPriceRet(HttpServletRequest request, CntrChargeDetailVo vo) {
        CntrChargeDetail chargeDetail = baseMapper.selectById(vo.getId());
        chargeDetail.setPrice(vo.getPrice());
        chargeDetail.setUpdateTime(LocalDateTime.now());
        boolean b = updateById(chargeDetail);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }
}
